# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.AndroidPublisher.V3.Model.ExternalTransaction do
  @moduledoc """
  The details of an external transaction.

  ## Attributes

  *   `createTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The time when this transaction was created. This is the time when Google was notified of the transaction.
  *   `currentPreTaxAmount` (*type:* `GoogleApi.AndroidPublisher.V3.Model.Price.t`, *default:* `nil`) - Output only. The current transaction amount before tax. This represents the current pre-tax amount including any refunds that may have been applied to this transaction.
  *   `currentTaxAmount` (*type:* `GoogleApi.AndroidPublisher.V3.Model.Price.t`, *default:* `nil`) - Output only. The current tax amount. This represents the current tax amount including any refunds that may have been applied to this transaction.
  *   `externalTransactionId` (*type:* `String.t`, *default:* `nil`) - Output only. The id of this transaction. All transaction ids under the same package name must be unique. Set when creating the external transaction.
  *   `oneTimeTransaction` (*type:* `GoogleApi.AndroidPublisher.V3.Model.OneTimeExternalTransaction.t`, *default:* `nil`) - This is a one-time transaction and not part of a subscription.
  *   `originalPreTaxAmount` (*type:* `GoogleApi.AndroidPublisher.V3.Model.Price.t`, *default:* `nil`) - Required. The original transaction amount before taxes. This represents the pre-tax amount originally notified to Google before any refunds were applied.
  *   `originalTaxAmount` (*type:* `GoogleApi.AndroidPublisher.V3.Model.Price.t`, *default:* `nil`) - Required. The original tax amount. This represents the tax amount originally notified to Google before any refunds were applied.
  *   `packageName` (*type:* `String.t`, *default:* `nil`) - Output only. The resource name of the external transaction. The package name of the application the inapp products were sold (for example, 'com.some.app').
  *   `recurringTransaction` (*type:* `GoogleApi.AndroidPublisher.V3.Model.RecurringExternalTransaction.t`, *default:* `nil`) - This transaction is part of a recurring series of transactions.
  *   `testPurchase` (*type:* `GoogleApi.AndroidPublisher.V3.Model.ExternalTransactionTestPurchase.t`, *default:* `nil`) - Output only. If set, this transaction was a test purchase. Google will not charge for a test transaction.
  *   `transactionProgramCode` (*type:* `integer()`, *default:* `nil`) - Optional. The transaction program code, used to help determine service fee for eligible apps participating in partner programs. Developers participating in the Play Media Experience Program (https://play.google.com/console/about/programs/mediaprogram/) must provide the program code when reporting alternative billing transactions. If you are an eligible developer, please contact your BDM for more information on how to set this field. Note: this field can not be used for external offers transactions.
  *   `transactionState` (*type:* `String.t`, *default:* `nil`) - Output only. The current state of the transaction.
  *   `transactionTime` (*type:* `DateTime.t`, *default:* `nil`) - Required. The time when the transaction was completed.
  *   `userTaxAddress` (*type:* `GoogleApi.AndroidPublisher.V3.Model.ExternalTransactionAddress.t`, *default:* `nil`) - Required. User address for tax computation.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :createTime => DateTime.t() | nil,
          :currentPreTaxAmount => GoogleApi.AndroidPublisher.V3.Model.Price.t() | nil,
          :currentTaxAmount => GoogleApi.AndroidPublisher.V3.Model.Price.t() | nil,
          :externalTransactionId => String.t() | nil,
          :oneTimeTransaction =>
            GoogleApi.AndroidPublisher.V3.Model.OneTimeExternalTransaction.t() | nil,
          :originalPreTaxAmount => GoogleApi.AndroidPublisher.V3.Model.Price.t() | nil,
          :originalTaxAmount => GoogleApi.AndroidPublisher.V3.Model.Price.t() | nil,
          :packageName => String.t() | nil,
          :recurringTransaction =>
            GoogleApi.AndroidPublisher.V3.Model.RecurringExternalTransaction.t() | nil,
          :testPurchase =>
            GoogleApi.AndroidPublisher.V3.Model.ExternalTransactionTestPurchase.t() | nil,
          :transactionProgramCode => integer() | nil,
          :transactionState => String.t() | nil,
          :transactionTime => DateTime.t() | nil,
          :userTaxAddress =>
            GoogleApi.AndroidPublisher.V3.Model.ExternalTransactionAddress.t() | nil
        }

  field(:createTime, as: DateTime)
  field(:currentPreTaxAmount, as: GoogleApi.AndroidPublisher.V3.Model.Price)
  field(:currentTaxAmount, as: GoogleApi.AndroidPublisher.V3.Model.Price)
  field(:externalTransactionId)
  field(:oneTimeTransaction, as: GoogleApi.AndroidPublisher.V3.Model.OneTimeExternalTransaction)
  field(:originalPreTaxAmount, as: GoogleApi.AndroidPublisher.V3.Model.Price)
  field(:originalTaxAmount, as: GoogleApi.AndroidPublisher.V3.Model.Price)
  field(:packageName)

  field(:recurringTransaction,
    as: GoogleApi.AndroidPublisher.V3.Model.RecurringExternalTransaction
  )

  field(:testPurchase, as: GoogleApi.AndroidPublisher.V3.Model.ExternalTransactionTestPurchase)
  field(:transactionProgramCode)
  field(:transactionState)
  field(:transactionTime, as: DateTime)
  field(:userTaxAddress, as: GoogleApi.AndroidPublisher.V3.Model.ExternalTransactionAddress)
end

defimpl Poison.Decoder, for: GoogleApi.AndroidPublisher.V3.Model.ExternalTransaction do
  def decode(value, options) do
    GoogleApi.AndroidPublisher.V3.Model.ExternalTransaction.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.AndroidPublisher.V3.Model.ExternalTransaction do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
